﻿using System;
using Gp.Scripts.Core;
using NRFramework;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;


public static class UIViewExtension
{
    public static T GetComponent<T>(this UIView self) where T : Component
    {
        return self.gameObject.GetComponent<T>();
    }

    public static void RemoveSelf(this UIPanel self)
    {
        if (Global.Get<GUIManager>().IsPeekPanel(self.panelId))
            Global.Get<GUIManager>().PopPanel();
    }

    public static void UpdateButton(this Button button, UnityAction onClick)
    {
        button.onClick.RemoveAllListeners();
        button.onClick.AddListener(onClick);
    }
}